<?php

class login extends Controller {

    function login () {
        parent::Controller();
        
        /*MODEL*/
        $this->load->model('users_m','usersm');
    }

    function index(){
        if($this->usersm->is_log(1)){
            redirect(site_url());
        }elseif($this->usersm->is_log(2)){
            redirect(site_url());
        }else{
            $this->load->view('login_v');
        }
    }

    function submit_login() {
        $response = $this->usersm->log_in();
        if($response['success'] == 'success') {
            if($response['row']['status'] == 1) {
                redirect(site_url());
            }elseif($response['row']['status'] == 2) {
                redirect(site_url().'home');
            }
        }else {
            $this->load->view('login_v',array('error'=>1,'message'=>$response['message']));
        }
    }

    function log_out(){
        $this->usersm->log_out();
        //$this->index();
        redirect('http://localhost/soho-exc');
        //redirect('http://www.informacionisistem.com');
    }
    
}
?>